﻿using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using UFIDA.U9.WSS.ProxyService.Behavior.WebHttp.Base;

namespace UFIDA.U9.WSS.ProxyService.Behavior.WebHttp
{
    public class ProxyServiceBehavior : NewtonsoftJsonBehavior
    {
        private readonly bool _accessProxy;
        private readonly bool _useDataContract;

        public ProxyServiceBehavior(bool useDataContract = false, bool accessProxy = false)
        {
            _useDataContract = useDataContract;
            _accessProxy = accessProxy;
        }

        protected override IDispatchMessageFormatter GetCustomDispatchFormatter(
            OperationDescription operationDescription)
        {
            return new ProxyServiceDispatchFormatter(operationDescription, _useDataContract, _accessProxy);
        }
    }
}